<template>
  <div>
    <h3 style="text-align: center;">阶段训练计划表</h3>
    <el-row class="top">
      <el-col :span="15">
        <plan-header ref="planHeader" :tableData="tableData" :titleShow="false"/>
      </el-col>
      <el-col :span="9">
        <ul class="top-text">
          <li>1.阶段训练计划全年训练不低于280个训练日（含竞赛）</li>
          <li>2.中等体育运动学校训练计划应体现每天训练时间控制在3.5小时以内（含早操）</li>
          <li>3.义务教育阶段的学生每天训练时间原则上控制在2.5小时之内（含早操）</li>
          <li>4.训练计划的安排应符合在训青少年年龄段的生理心理特点。</li>
          <li>运动负荷量和强度不能超过100。</li>
        </ul>
      </el-col>
    </el-row>
    <el-button v-show="!docExcelId" @click="addDocExcel" type="primary" size="small" icon="el-icon-s-promotion" style="position: absolute;right: 30px;top: 400px;">创建</el-button>
    <div id="app"  v-show="docExcelId" class="row">
      <div class="col-md-12">
          <section class="panel">
              <header class="panel-heading ">
                  <h3 class="panel-title">{{docExcelInfo.name||defaultData.name}}</h3>
              </header>
              <div ref="excel" id="excel">
                  <div class="row" style="height: auto; padding: 0 15px;text-align: center;overflow: hidden;">
                      <div   v-show="docExcelId" style="margin:0px;padding:0px;display: none;">
                          <table border="1" style="font-size: 12px" id="table4TrainExcel" >
                              <tr>
                                  <td>月份</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.month"><input class="topInputStyle" type="text" v-model="resData.month[name]"></td>

                              </tr>

                              <tr>
                                  <td>一般素质</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.generalQuality"><input class="topInputStyle" type="text" v-model="resData.generalQuality[name]"></td>

                              </tr>

                              <tr>
                                  <td>专项素质</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.specialQuality"><input class="topInputStyle" type="text" v-model="resData.specialQuality[name]"></td>

                              </tr>

                              <tr>
                                  <td>技术</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.technology"><input class="topInputStyle" type="text" v-model="resData.technology[name]"></td>

                              </tr>

                              <tr>
                                  <td>战术</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.tactics"><input class="topInputStyle" type="text" v-model="resData.tactics[name]"></td>

                              </tr>

                              <tr>
                                  <td>理论与其他</td>
                                  <td colspan="4" v-for="(item,name,index) in resData.longTextOne"><input class="topInputStyle" type="text" v-model="resData.longTextOne[name]"></td>

                              </tr>
                              <tr>
                                  <td width="80px">周</td>
                                  <td v-for="(item,name,index) in resData.week"><input class="topInputStyle bottomInputStyle" type="text"  v-model="resData.week[name]"></td>
                                  <td >48</td>
                              </tr>
                              <tr>
                                  <td width="80px">训练次数</td>
                                  <td v-for="(item,name,index) in resData.trainingTimes"><input class="topInputStyle bottomInputStyle" type="text"  v-model="resData.trainingTimes[name]"></td>
                                  <td width="80px" v-text="getTrainingTimesNumSum"></td>
                              </tr>
                              <tr>
                                  <td width="80px">训练时数</td>
                                  <td v-for="(item,name,index) in resData.trainingHours"><input class="topInputStyle bottomInputStyle" type="text"  v-model="resData.trainingHours[name]"></td>
                                  <td width="80px" v-text="getTrainingHoursTimesNumSum"></td>
                              </tr>
                              <tr>
                                  <td width="80px">负荷量</td>
                                  <td v-for="(item,name,index) in resData.loadCapacity"><input class="topInputStyle bottomInputStyle" type="text" @change="reDrawEcharts"  v-model="resData.loadCapacity[name]"></td>
                                  <td width="80px" v-text="getLoadCapacityNumSum"></td>
                              </tr>
                              <tr>
                                  <td width="80px">负荷强度</td>
                                  <td v-for="(item,name,index) in resData.loadStrength"><input class="topInputStyle bottomInputStyle" type="text" @change="reDrawEcharts" v-model="resData.loadStrength[name]"></td>
                                  <td width="80px" v-text="getLoadStrengthNumSum"></td>
                              </tr>
                              <tr>
                                  <td colspan="50" height="160px" style="position: relative;">
                                      <span style="display: inline-block;height: 100%;width: 80px;position: absolute;left: 0;top: 0;line-height: 35px">负<br>荷<br>曲<br>线</span>
                                      <div style="display: inline-block;width: 100%;height: 100%;box-sizing:border-box;padding-left: 80px;position: absolute;right:0px;top: 0px;" id="clearNothing">
                                          <div id="personCharts" style="height: 100%;"></div>
                                      </div>
                                  </td>
                              </tr>
                              <tr >
                                  <td>年度任务</td>
                                  <td colspan="50"><textarea class="centerTextareaStyle" v-model="resData.AnnualTasks['0']"></textarea></td>
                              </tr>
                              <tr>
                                  <td>基本期</td>
                                  <td colspan="6">日期</td>
                                  <td colspan="23">各阶段主要训练内容</td>
                                  <td colspan="23">各阶段主要训练措施、方法、手段</td>
                              </tr>
                              <tr v-for="(item,name,index) in resData.longText4Arr">
                                  <td><input class="topInputStyle bottomInputStyle" type="text" v-model="resData.longText4Arr[name]['0']"></td>
                                  <td colspan="6"><input class="topInputStyle bottomInputStyle" type="text" v-model="resData.longText4Arr[name]['1']"></td>
                                  <td colspan="23"><textarea class="centerTextareaStyle" v-model="resData.longText4Arr[name]['2']"></textarea></td>
                                  <td colspan="23"><textarea class="centerTextareaStyle" v-model="resData.longText4Arr[name]['3']"></textarea></td>
                              </tr>

                          </table>
                          <div style="display: flex;justify-content: space-between;align-items: center;margin: 10px 0;">
                            <el-button v-show="!isPreview" @click="colIdAndChanges" size="small" icon="el-icon-plus" type="primary">添加周期</el-button>
                            <el-button v-show="!isPreview" @click="saveDataBtn" size="small" type="primary" icon="iconfont icon-save">保 存</el-button>
                            <el-button @click="printTable" size="small" icon="el-icon-printer" type="primary"> 打印</el-button>
                          </div>
                      </div>
                  </div>
              </div>
          </section>
      </div>
  </div>
  <!-- 打印 -->
  <vxe-modal v-model="printModal" title="预览" height="800" show-zoom resize width="1200" show-footer>
    <template #default>
      <docExcelPrint v-if="printModal" id="myPrint" ref="docExcelPrint" :resData="resData" :docExcelId="docExcelId" :docExcelInfo="docExcelInfo" :planForm="planForm" :dict_emp="dict_emp" :dict_sport="dict_sport"></docExcelPrint>
    </template>
    <template #footer>
      <el-button @click="printEvent" type="primary" icon="el-icon-printer" size="mini">打印</el-button>
    </template>
  </vxe-modal>
  </div>
</template>

<script>
  import {  currentRoleEmployee,pcm4emp } from '@/api/person.js'
  import {  get_sport ,sport_item} from '@/api/dict.js'
  import { defaultOption4newPeriodPlan,doc_excel_key,doc_excel_update,doc_excel_insert} from '@/api/plan.js'
  import planHeader from "@/components/plan/planHeader.vue"
  import docExcelPrint from "@/components/print/docExcelPrint.vue"
  import * as echarts from 'echarts';
  export default {
    components: {
      planHeader,
      docExcelPrint
    },
    data() {
      return {
        tableData: {},
        tableHeader: [],
        dict_sport: {},
        dict_sportItem: {},
        dict_emp: {},
        dict_docDataEmp: {},
        defaultData: {},
        reqData:{},
        resData:{
            month:{  //月份
                0:"1",
                1:"2",
                2:"3",
                3:"4",
                4:"5",
                5:"6",
                6:"7",
                7:"8",
                8:"9",
                9:"10",
                10:"11",
                11:"12",
                12:"小计平均"

            },
            generalQuality:{  //一般素质
                0:"50%",
                1:"50%",
                2:"50%",
                3:"",
                4:"",
                5:"",
                6:"",
                7:"",
                8:"",
                9:"",
                10:"",
                11:"",
                12:""
            },
            specialQuality:{  //专项素质
                0:"15%",
                1:"15%",
                2:"15%",
                3:"",
                4:"",
                5:"",
                6:"",
                7:"",
                8:"",
                9:"",
                10:"",
                11:"",
                12:""
            },
            technology:{  //技术
                0:"10%",
                1:"20%",
                2:"20%",
                3:"",
                4:"",
                5:"",
                6:"",
                7:"",
                8:"",
                9:"",
                10:"",
                11:"",
                12:""
            },
            tactics:{  //战术
                0:"10%",
                1:"10%",
                2:"10%",
                3:"",
                4:"",
                5:"",
                6:"",
                7:"",
                8:"",
                9:"",
                10:"",
                11:"",
                12:""
            },
            longTextOne:{  //理论与其他
                0:"15%",
                1:"5%",
                2:"5%",
                3:"",
                4:"",
                5:"",
                6:"",
                7:"",
                8:"",
                9:"",
                10:"",
                11:"",
                12:""
            },
            AnnualTasks:{  //年度任务
                0:"抓训练作风，严格管理，严格训练。提高身体素质水平，发展力量、速度、耐力等素质能力。观察入微，根据个人特点扬长避短，改进专项技术和跑步技术。培养荣誉感和不怕苦不怕累的顽强拼搏精神。",
                1:""
            },
            week:{  //周
                0:"1",
                1:"2",
                2:"3",
                3:"4",
                4:"5",
                5:"6",
                6:"7",
                7:"8",
                8:"9",
                9:"10",
                10:"11",
                11:"12",
                12:"13",
                13:"14",
                14:"15",
                15:"16",
                16:"17",
                17:"18",
                18:"19",
                19:"20",
                20:"21",
                21:"22",
                22:"23",
                23:"24",
                24:"25",
                25:"26",
                26:"27",
                27:"28",
                28:"29",
                29:"30",
                30:"31",
                31:"32",
                32:"33",
                33:"34",
                34:"35",
                35:"36",
                36:"37",
                37:"38",
                38:"39",
                39:"40",
                40:"41",
                41:"42",
                42:"43",
                43:"44",
                44:"45",
                45:"46",
                46:"47",
                47:"48"
            },
            trainingTimes:{  //训练次数
                0:"6",
                1:"6",
                2:"6",
                3:"6",
                4:"7",
                5:"7",
                6:"7",
                7:"6",
                8:"6",
                9:"6",
                10:"2",
                11:"4",
                12:"",
                13:"",
                14:"",
                15:"",
                16:"",
                17:"",
                18:"",
                19:"",
                20:"",
                21:"",
                22:"",
                23:"",
                24:"",
                25:"",
                26:"",
                27:"",
                28:"",
                29:"",
                30:"",
                31:"",
                32:"",
                33:"",
                34:"",
                35:"",
                36:"",
                37:"",
                38:"",
                39:"",
                40:"",
                41:"",
                42:"",
                43:"",
                44:"",
                45:"",
                46:"",
                47:""
            },
            trainingHours:{  //训练时数
                0:"16",
                1:"16",
                2:"16",
                3:"19",
                4:"19",
                5:"19",
                6:"20",
                7:"15",
                8:"16",
                9:"16",
                10:"4",
                11:"15",
                12:"",
                13:"",
                14:"",
                15:"",
                16:"",
                17:"",
                18:"",
                19:"",
                20:"",
                21:"",
                22:"",
                23:"",
                24:"",
                25:"",
                26:"",
                27:"",
                28:"",
                29:"",
                30:"",
                31:"",
                32:"",
                33:"",
                34:"",
                35:"",
                36:"",
                37:"",
                38:"",
                39:"",
                40:"",
                41:"",
                42:"",
                43:"",
                44:"",
                45:"",
                46:"",
                47:""
            },
            loadCapacity:{  //负荷量
                0:"80",
                1:"85",
                2:"90",
                3:"95",
                4:"70",
                5:"50",
                6:"50",
                7:"60",
                8:"70",
                9:"80",
                10:"80",
                11:"85",
                12:"",
                13:"",
                14:"",
                15:"",
                16:"",
                17:"",
                18:"",
                19:"",
                20:"",
                21:"",
                22:"",
                23:"",
                24:"",
                25:"",
                26:"",
                27:"",
                28:"",
                29:"",
                30:"",
                31:"",
                32:"",
                33:"",
                34:"",
                35:"",
                36:"",
                37:"",
                38:"",
                39:"",
                40:"",
                41:"",
                42:"",
                43:"",
                44:"",
                45:"",
                46:"",
                47:""
            },
            loadStrength:{  //负荷强度
                0:"40",
                1:"50",
                2:"60",
                3:"70",
                4:"80",
                5:"90",
                6:"95",
                7:"85",
                8:"75",
                9:"65",
                10:"55",
                11:"45",
                12:"",
                13:"",
                14:"",
                15:"",
                16:"",
                17:"",
                18:"",
                19:"",
                20:"",
                21:"",
                22:"",
                23:"",
                24:"",
                25:"",
                26:"",
                27:"",
                28:"",
                29:"",
                30:"",
                31:"",
                32:"",
                33:"",
                34:"",
                35:"",
                36:"",
                37:"",
                38:"",
                39:"",
                40:"",
                41:"",
                42:"",
                43:"",
                44:"",
                45:"",
                46:"",
                47:""
            },
            longText4Arr:{
                text0:{
                    0:"准备期",
                    1:"2021.1.1-2021.5.1",
                    2:"一般准备阶段: \n 专项准备阶段:",
                    3:"一般准备阶段: \n 专项准备阶段:"
                },
                text1:{
                    0:"比赛期",
                    1:"2021.5.1-2021.10.1",
                    2:"",
                    3:""
                },
                text2:{
                    0:"恢复期",
                    1:"2021.10.1-2021.12.31",
                    2:"",
                    3:""
                }
            }
        },
        docExcelId : '',
        docExcelInfo: {},
        printModal: false,
        planForm: {},
        isPreview: false,
      }
    },
    created() {
      this.docExcelId = this.$route.query.docExcelId
      this.isPreview = this.$route.query.isPreview
      this.init_dict().then(()=>{
        setTimeout(()=>{
          this.getTableData()
        },300)
      })
    },
    mounted() {


      // doc_excel_update({"docClassId":2,"excelData":JSON.stringify(this.resData),"docExcelId":this.docExcelId}).then(res=> {
      //   if(res.code === 200) {
      //     this.$message.success('保存成功！')
      //   }else{
      //     this.$message.error(res.message)
      //   }
      // });
  },
  computed: {
      getTrainingTimesNumSum: {
          //cache:false,
          get :function(){
              let getTrainingTimesNumSum = 0;
              let TrainingTimesDivisor = 0
              //cache:false
              // for (let i=0;i< this.resData.trainingTimes.length;i++){
              //     console.log(1111)
              //     getTrainingTimesNumSum += this.resData.trainingTimes[i]
              // }

              for (let item in this.resData.trainingTimes) {
                  // console.log(item)
                  if(this.resData.trainingTimes[item] && this.resData.trainingTimes[item] != 0){
                      getTrainingTimesNumSum += Number(this.resData.trainingTimes[item])
                      TrainingTimesDivisor++
                  }
              }

              return getTrainingTimesNumSum
              // console.log(parseFloat(getNumSum))
              // if(parseFloat(getTrainingTimesNumSum)){
              //     return parseFloat(getTrainingTimesNumSum).toFixed(2);
              // }else{
              //     return '111';
              // }

          }

      },
      getTrainingHoursTimesNumSum: {
          //cache:false,
          get :function(){
              let getTrainingHoursNumSum = 0;
              let TrainingHoursDivisor = 0
              for (let item in this.resData.trainingHours) {
                  // console.log(item)
                  if(this.resData.trainingHours[item] && this.resData.trainingHours[item] != 0){
                      getTrainingHoursNumSum += Number(this.resData.trainingHours[item])
                      TrainingHoursDivisor++
                  }
              }
              return getTrainingHoursNumSum

          }

      },
      getLoadCapacityNumSum: {
          //cache:false,
          get :function(){
              let getLoadCapacityNumSum = 0;
              let LoadCapacityDivisor = 0
              for (let item in this.resData.loadCapacity) {
                  // console.log(item)
                  if(this.resData.loadCapacity[item] && this.resData.loadCapacity[item] != 0){
                      getLoadCapacityNumSum += Number(this.resData.loadCapacity[item])
                      LoadCapacityDivisor++
                  }
              }
              return parseFloat(getLoadCapacityNumSum/LoadCapacityDivisor).toFixed(2);

          }

      },
      getLoadStrengthNumSum: {
          //cache:false,
          get :function(){
              let getLoadStrengthNumSum = 0;
              let LoadStrengthDivisor = 0
              for (let item in this.resData.loadStrength) {
                  // console.log(item)
                  if(this.resData.loadStrength[item] && this.resData.loadStrength[item] != 0){
                      getLoadStrengthNumSum += Number(this.resData.loadStrength[item])
                      LoadStrengthDivisor++
                  }
              }
              return parseFloat(getLoadStrengthNumSum/LoadStrengthDivisor).toFixed(2);

          }

      }
  },
    methods: {
      addDocExcel() {
        let headerData = this.$refs.planHeader.planForm
        let doubleDate = this.$store.state.user.planDate
        let json = {
          openDate: this.$moment(doubleDate[0]).format('YYYY-MM-DD') + ' 00:00:00',
          closeDate: this.$moment(doubleDate[1]).format('YYYY-MM-DD') + ' 00:00:00',
          sportId: headerData.sportId,
          name: headerData.name,
          empId: headerData.empId,
          signers: headerData.docDataEmpId.join(','),
          createDate: this.$moment(headerData.createDate).format('YYYY-MM-DD') + ' 00:00:00',
          docClassId: 2,
        }
        doc_excel_insert(json).then(res=>{
          if(res.code === 200){
            this.docExcelId = res.data.docExcelId
            this.docExcelInfo = res.data
            this.doc_excel_key()
            this.$message.success('创建成功！')
          }else{
            this.$message.error(res.message)
          }
        })
      },
      doc_excel_key() {
        var that = this
        doc_excel_key({"docExcelId":this.docExcelId}).then((result)=>{ //获取初始值
            if(result.code != 200) {
              return
            }
            that.defaultData = result.data
            if(result.data.excelData){
                that.resData = JSON.parse(result.data.excelData)
            }
            let personCharts = echarts.init(document.getElementById('personCharts'));
            let planChartsOption = {
                title: {
                    text: ''
                },
                tooltip: {},
                grid:{
                    height:90,
                    top:40,
                    left:100

                },
                legend: {
                    orient: 'vertical',
                    x: 1450,
                    y: 'top',
                    data:['负荷量','负荷强度']
                },
                xAxis: {
                    data: Object.values(that.resData.week),
                    // axisLabel: {
                    //     interval:0,
                    //     rotate:40,
                    //     textStyle: {
                    //         color: "#a9a9a9", //更改坐标轴文字颜色
                    //         fontSize: 10 //更改坐标轴文字大小
                    //     },
                    // },
                },
                yAxis: {},
                series: [{
                    name: '负荷量',
                    type: 'line',
                    data: Object.values(that.resData.loadCapacity),
                    "connectNulls": true
                },{
                    name: '负荷强度',
                    type: 'line',
                    symbol:'diamond',
                    symbolSize:8,
                    data: Object.values(that.resData.loadStrength),
                    "connectNulls": true
                }],
                color:['#0180CD','#FF4D4D']
            };

            // 使用刚指定的配置项和数据显示图表。
            personCharts.setOption(planChartsOption);

        })
      },
      colIdAndChanges:function(){
          let newLongTextKey = "text" + Object.keys(this.resData.longText4Arr).length;
          let newLongTextVlaue = {
              0:"",
              1:"",
              2:"",
              3:""
          }

          this.$set(this.resData.longText4Arr,newLongTextKey,newLongTextVlaue)
      },
      saveDataBtn:function(){
          let needCheckRow = ["generalQuality","specialQuality","technology","tactics","longTextOne"]
          let pass = true;
          for (let mIndex = 0; mIndex < 12; mIndex++) {
              let totalPercent = 0;

              needCheckRow.forEach(value => {
                  let cValue = this.resData[value][mIndex]

                  if(cValue && !isNaN(parseFloat(cValue))){
                      totalPercent+= parseFloat(cValue)
                  }else{
                      // todo 提示用户录入格式不正确
                      // console.log("当前值不可用"+cValue)

                  }

              })
              if(totalPercent>100){
                  pass = false;
                  this.$message.warning('请检查每列总和是否为100%及该数据格式！')
                  break;
              }
          }
          // console.log(pass)
          if(pass){
            let headerData = this.$refs.planHeader.planForm
            let doubleDate = this.$store.state.user.planDate
            let json = {
              beginDate: this.$moment(doubleDate[0]).format('YYYY-MM-DD') + ' 00:00:00',
              endDate: this.$moment(doubleDate[1]).format('YYYY-MM-DD') + ' 00:00:00',
              sportId: headerData.sportId,
              name: headerData.name,
              empId: headerData.empId,
              signers: headerData.docDataEmpId.join(','),
              createDate:  this.$moment(headerData.createDate).format('YYYY-MM-DD') + ' 00:00:00',
              docClassId: 2,
              excelData: JSON.stringify(this.resData),
              docExcelId: this.docExcelId,
            }
            doc_excel_update(json).then(result=> {
                if(result.code === 200) {
                    this.$notify({
                      title: '成功',
                      message: '保存成功',
                      type: 'success',
                      duration: 0,
                      position: 'bottom-right'
                    });
                   this.$message.success('保存成功！')
                }else{
                  this.$message.error('保存失败，请检查数据格式')
                }
            });
          }


      },
      reDrawEcharts:function(){
          let personCharts = echarts.init(document.getElementById('personCharts'));
          let planChartsOption = {
              title: {
                  text: ''
              },
              tooltip: {},
              grid:{
                  height:90,
                  top:40,
                  left:100

              },
              legend: {
                  orient: 'vertical',
                  x: 1200,
                  y: 'top',
                  data:['负荷量','负荷强度']
              },
              xAxis: {
                  data: Object.values(this.resData.week),
                  // axisLabel: {
                  //     interval:0,
                  //     rotate:40,
                  //     textStyle: {
                  //         color: "#a9a9a9", //更改坐标轴文字颜色
                  //         fontSize: 10 //更改坐标轴文字大小
                  //     },
                  // },
              },
              yAxis: {},
              series: [{
                  name: '负荷量',
                  type: 'line',
                  data: Object.values(this.resData.loadCapacity),
                  "connectNulls": true
              },{
                  name: '负荷强度',
                  type: 'line',
                  symbol:'diamond',
                  symbolSize:8,
                  data: Object.values(this.resData.loadStrength),
                  "connectNulls": true
              }],
              color:['#0180CD','#FF4D4D']
          };
          // 使用刚指定的配置项和数据显示图表。
          personCharts.setOption(planChartsOption);
      },
      printEvent() {
        this.$refs.docExcelPrint.print()
        document.title = '阶段训练计划表'+'-'+this.dict_sport[this.planForm.sportId]+'-'+this.dict_emp[this.planForm.empId]+'-'+this.$moment(this.planForm.doubleDate[0]).format('YYYY-MM-DD')+'至'+this.$moment(this.planForm.doubleDate[1]).format('YYYY-MM-DD')
        setTimeout(()=>{
          const divEl = document.getElementById('myPrint')
          this.$XPrint({
            sheetName: '阶段训练计划表',
            content: divEl.innerHTML
          })
        },1000)
      },
      printTable:function(){
          // this.saveDataBtn()
          this.planForm = this.$refs.planHeader.planForm
          this.planForm.doubleDate = this.$store.state.user.planDate
          this.printModal = true
          // this.$router.push('/docExcelPrint')
      },
      getTableData() {
        if(this.defaultData.name){
          this.tableHeader[0] = {content: this.defaultData.name,name: "标题"}
        }else{
          this.tableHeader[0] = {content: '阶段训练计划表',name: "标题"}
        }
        if(!this.defaultData.beginDate){
          this.tableHeader[1] = {
            openDate: this.$moment(this.defaultData.beginDate).startOf('year').format("YYYY-MM-DD"),
            closeDate: this.$moment(this.defaultData.endDate).endOf('year').format("YYYY-MM-DD"),
            name: "日期范围",
          }
        }else{
          this.tableHeader[1] = {
            openDate: this.$moment(this.defaultData.beginDate).format("YYYY-MM-DD"),
            closeDate: this.$moment(this.defaultData.endDate).format("YYYY-MM-DD"),
            name: "日期范围",
          }
        }

        this.tableHeader[2] = {
          content: this.dict_sport,
          defaultOption: this.defaultData.sportId,
          name: "运动项目",
        }
        this.tableHeader[3] = {
          content: {},
          defaultOption: this.defaultData.sportItemId,
          name: "运动小项",
        }
        this.tableHeader[4] = {
          content: this.dict_emp,
          defaultOption: this.defaultData.empId,
          name: "撰写者",
        }
        this.tableHeader[5] = {
          content: this.dict_docDataEmp,
          defaultSigners: this.defaultData.signers,
          name: "撰写署名",
        }
        this.tableHeader[6] = {name: "撰写日期",defaultCreateDate:this.defaultData.createDate}
        this.tableData = {
          tableHeader: this.tableHeader,
          tableBody: [],
          title: {name: this.defaultData.name||"阶段训练计划表"},
        }
      },
      init_dict() {
        return new Promise((resolve,reject)=>{
          get_sport().then(res=>{
            this.dict_sport = res
          })
          sport_item().then(res=>{
            this.dict_sportItem = res
          })
          currentRoleEmployee().then(res=>{
            res.data.forEach(item=>{
              this.dict_emp[item.empId] = item.name
            })
          }).then(()=>{
            if(this.docExcelId){
              this.doc_excel_key()
            }else{
              defaultOption4newPeriodPlan().then(res=>{
                this.defaultData = res.data
              })
            }
            pcm4emp({sportId:this.defaultData.sportId}).then(res=>{
              res.data.forEach(item=>{
                this.dict_docDataEmp[item.empId] = item.name
              })
              resolve()
            })
          })
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  #app{
    background-color: #FFFFFF;
    margin-top: 20px;
  }
input{
    outline: none;
}
.table > tbody > tr > td {
    border: 1px solid black;
    font-family: "宋体";
    font-size: 14px;

}
.table  tbody  tr td p,span{
    /*font-family: "宋体";*/
    /*font-size: 16px;*/

}

.force-width {
    min-width: 110px;
}



tbody, table {
    width: 100%;
    font-family: "宋体";
    font-size: 14px;
    border-collapse: collapse;
}

.table {
    width: 100%;
    vertical-align: middle;
    min-height: 800px;
    font-family: "宋体";
    font-size: 16px;
}

@media print {
    .next-page {
        page-break-after: always;
    }
}

.first-level-title {
    font-weight:bold;
    font-size: 21px;
    text-align: center;
    font-family: "宋体";
}

.second-level-title {
    font-size: 16px;
    text-align: center;
    font-family: "宋体";
}
.topInputStyle{
    width: 80px;
    height: 100%;
    display: inline-block;
    text-align:center;
    border: none;
}

.centerTextareaStyle{
    width: 100%;
    height: 100px;
    border: none;
    outline:none;
    resize: none;
    overflow-y: hidden;
    font-size: 10px;
}

#table4TrainExcel .bottomInputStyle{
    width: 100%;
}
.top{
  background-color: #FFFFFF;
}
.top-text{
  li{
    list-style: none;
    color: red;
    font-size: 18px;
    margin: 20px;
  }
}
</style>
